/*!***************************************************
 * @file: func_app.h
 * @brief: 实现好友和通信功能的应用逻辑
 * @author: ITHAO 
 * @date: 2018.12.12
 * @note: 
 ****************************************************/
#ifndef __FUNC_APP_H__
#define __FUNC_APP_H__

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "func.h"

/*这里不能直接包含app.h，因为app.h也要包含当前头文件，
如果直接包含app.h会发生头文件嵌套包含的情况，
本文件定义的结构体就会在app.h定义不到*/
struct mutexfd;

enum {
    FUNCAPP_LOAD_FAIL                = 2,
    FUNCAPP_ADD_FAIL                 = 3,
    FUNCAPP_REMOVE_FAIL              = 4,
    FUNCAPP_OWNER_ACCOUNT_NOT_EXIST  = 5,
    FUNCAPP_FRIEND_ACCOUNT_NOT_EXIST = 6, /*ok*/
    FUNCAPP_NOT_FRIEND               = 7, /*ok*/
    FUNCAPP_SHORT_OF_DATA            = 8,
    FUNCAPP_FRIEND_ADD_OWNER_FAIL    = 9,
    FUNCAPP_IS_ALREADY_FRIEND        = 10,/*ok*/
    FUNCAPP_EXCEED_FRIEND_NUM        = 11,
    FUNCAPP_FRIEND_RMOVE_OWNER_FAIL  = 12,
    FUNCAPP_FRIEND_IS_OWNER          = 13,
    FUNCAPP_NO_FRIEND                = 14,/*ok*/
};

enum {
    FUNCAPP_PARAM_NULL_ERR  = 1,
    FUNCAPP_FD_INVALID_ERR,
    FUNCAPP_SEND_ERR,
    FUNCAPP_RECV_ERR,
};

extern int send_msg(struct mutexfd *mutexfd, struct chat_packet chat_packet);

extern void friend_list_head_init(struct list_head *friend_list_head);

extern int load_friend(struct mutexfd *mutexfd, char *owner_account, 
                       struct list_head *friend_list_head);
extern int add_friend(char *owner_account, char *friend_account,
            struct list_head *friend_list_head, struct mutexfd *mutexfd);
extern int remove_friend(char *owner_account, char *friend_account,
            struct list_head *friend_list_head, struct mutexfd *mutexfd);
extern void destroy_friend_list(struct list_head *friend_list_head);

extern void show_friend(struct list_head *friend_list_head);



#endif
